Repository navigation
Conversation
v128 results with i64 or f64 lanes were never asserted (10,150 checks across the SIMD wasts), and v128 assertions always read the start of the results array instead of the result's own slots. Results are now indexed by slot (two per v128), and i64 lane values accept unsigned decimals.
The compiler used to reject any module with a v128 op. A v128 is now two longs, low word first, on the operand stack, in locals and in method parameters; results with a v128 take the long[] multi-value path, and the long[] call ABI holds a v128 as two entries, as the interpreter does. Compute ops call V128Words static helpers, one per 64-bit word of the result. Shuffles and ops that are one JVM instruction per word (v128 bitwise, i64x2 add/sub/mul/neg/shifts/lanes) are emitted inline, since with every op a helper C2 hits DesiredMethodLimit in large SIMD functions. SimdOp and V128Emitter check at class init that every v128 opcode is registered and has exactly one helper. Compiled classes stay Java 11. All SIMD spec wasts now run against compiled code. New tests compare each op with the interpreter and cover v128 across calls, host imports, globals, tags, tail calls, select/br_table and split functions. BasicSimdTest moves to machine-tests to run on both engines. The docs tell users to compare against a build without SIMD, since code vectorised throughout can run about 2x slower than its plain build.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The runtime and build-time compilers now run WebAssembly SIMD. Until now, any module with a
v128op could only run in the interpreter (#205).v128is twolongs, low word first. That holds on the operand stack, in locals and in method parameters.v128take the existinglong[]multi-value path.long[]call ABI av128takes two entries, as in the interpreter.invokestaticof aV128Wordshelper, one call per 64-bit word of the result. This follows theOpcodeImplpattern.SimdOpdoesn't register every0xFDopcode, or if any op lacks exactly one@OpCodeIdentifierhelper.The first commit is a separate test-gen fix. Before it,
v128results with i64 or f64 lanes were never asserted, about 10k checks across the SIMD wasts.Testing
simd_*.wastspec files now run against compiled code. Before, they were excluded.SimdOpDifferentialTestruns each of the 192 compute ops compiled and interpreted, on edge cases and 2,000 random operands.SimdBoundaryTestpassesv128values across:call_indirect,call_refand tail calls;selectandbr_table;BasicSimdTestmoves tomachine-tests, so it runs on both engines. That covers the check that a trapping store writes nothing.ManyParamsAbiTestaddsv128parameters around the 255-slot boxing threshold.mvn install: green on JDK 21. The compiler suites are also green on JDK 11.Investigation
We compared four ways to compile
v128on JDK 25. The payloads were libsodium (argon2id, aegis256), OpenSSL ChaCha20, and small byte, float and ChaCha20 kernels, each built with and without-msimd128:jdk.incubator.vector);The Vector API is fast in places but fragile:
LiveNodeCountInliningCutoff, and the vectors get boxed at 7.7 GB/op.It doesn't reach the hand-written numbers either. For the same row-vector ChaCha20, hand-written Vector API Java runs in 0.116 ms. Compiled from wasm with the Vector API backend, it takes 0.225 ms, slower than the plain wasm build at 0.198 ms. Compiled code reaches memory through the
Memoryinterface, and those calls stay out of line next to vector code. The memory path is the bigger lever for every backend.Static helpers perform about like inline scalar. They come within about 6% on the crypto payloads, with much less code: plain Java helpers instead of about 3,400 lines of ASM emitters.
Calling a helper for every op was too slow. C2 hit
DesiredMethodLimitin large functions, and argon2id ran 4.4× slower than plain. Moving shuffles and the one-instruction ops inline fixed it, and that hybrid is what this PR ships.This PR against the same source built without SIMD (JDK 25; the machine was noisy, so compare ratios):
SIMD builds win where clang turned byte loops into 16-byte operations. They lose where 32-bit lane rotates or float lanes are emulated on 64-bit words; plain scalar wasm gets native rotate instructions there.
Why scalar helpers first
--add-modules jdk.incubator.vector, and an incubator API that still changes. This keeps Java 11 and zero flags.Follow-ups (not in this PR)
V128Wordsinstead of its ownV128Ops.i8x16.shuffleas a 32-bit lane rotate, and rotate folding.